﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Media.Imaging;

namespace DocumentToBitmaps
{
    public class DocumentConverter
    {
        public static List<Image> ConvertToImages(string path)
        {
            List<Image> images = new List<Image>();
            //images.Add(CreateSampleImage());
            return images;
        }

        public static Image CreateSampleImage(Canvas surface)
        {
            RenderTargetBitmap renderBitmap = new RenderTargetBitmap(500, 600, 96d, 96d, PixelFormats.Pbgra32);
            renderBitmap.Render(surface);
            Image image = new Image();
            image.Source = renderBitmap;

            using (FileStream outStream = new FileStream(@"E:\pic.png", FileMode.Create))
            {
                PngBitmapEncoder encoder = new PngBitmapEncoder();
                encoder.Frames.Add(BitmapFrame.Create(renderBitmap));
                encoder.Save(outStream);
            }

            return image;
        }
    }
}
